import 'package:elephant_fish/page/index_charm_rank_page.dart';
import 'package:elephant_fish/page/index_rank_weekend_page.dart';
import 'package:elephant_fish/util/size_util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';


class IndexRankHomePage extends StatefulWidget {
  const IndexRankHomePage({Key key}) : super(key: key);

  @override
  _IndexRankHomePageState createState() => _IndexRankHomePageState();
}

class _TabData {
  final Widget tab;
  final Widget body;
  _TabData({this.tab, this.body});
}

final _tabDataList = <_TabData>[
  _TabData(tab: Text('周&星榜'), body: IndexRankWeekendPage(categoryName: '周&星榜',)),
  _TabData(tab: Text('年度风云榜'), body: IndexRankWeekendPage(categoryName: '年度风云榜',)),
];

class _IndexRankHomePageState extends State<IndexRankHomePage> {
  final tabBarList = _tabDataList.map((item) => item.tab).toList();
  final tabBarViewList = _tabDataList.map((item) => item.body).toList();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: DefaultTabController(
        length: tabBarList.length,
        child: Scaffold(
          appBar: AppBar(
            automaticallyImplyLeading: false,
            backgroundColor: Color(0xff140c3d),
            title: Row(
              children: [
                Expanded(child: TabBar(
                  // isScrollable: true, //可滚动
                  indicatorColor: Color(0xffffffff), //指示器的颜色
                  labelColor: Color(0xffffffff), //选中文字颜色
                  unselectedLabelColor: Color(0xffe1e1e1), //为选中文字颜色
                  isScrollable: true,
                  unselectedLabelStyle: TextStyle(
                    fontSize: SizeUtil.px(30),
                  ),
                  labelStyle: TextStyle(
                    fontSize: SizeUtil.px(30),
                  ),
                  // indicatorSize: TabBarIndicatorSize.label, //指示器与文字等宽
                  tabs: tabBarList,
                ),

                ),

              ],
            ),
          ),
          body:
          TabBarView(
              children: tabBarViewList
          ),
        ),
      ),
    );
  }
}
